Skip to content

Add maintenance.py tool with fixed templates and comprehensive documentation#2

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-e88a060a-e597-4a5f-9819-d179494d0799
Draft

Add maintenance.py tool with fixed templates and comprehensive documentation#2
Copilot wants to merge 4 commits intomainfrom
copilot/fix-e88a060a-e597-4a5f-9819-d179494d0799

Conversation

Copy link
Contributor

Copilot AI commented Oct 5, 2025

  • Analyze the problem statement and identify the issue
  • Create cleaned-up maintenance.py script with proper formatting
  • Add comprehensive documentation (MAINTENANCE_GUIDE.md)
  • Remove all icons and emoji from all files
    • maintenance.py: replaced box-drawing chars (+=|), check marks ([+]/[x]/[!]), bullets (-), section dividers (---)
    • MAINTENANCE_GUIDE.md: replaced color emoji with plain text labels
    • Fixed escape sequence warning introduced by replacement
  • Validate Python syntax and clean runtime execution
Original prompt

please clean this up
/dev/mapper/rhel-root",
"is_lvm": true,
"vg_name": "rhel",
"lv_name": "root"
}'

echo -e "\n\nTest completed"
""",

    'test_email_notifications.sh': """#!/bin/bash

Test email notifications

echo "Testing email notification configuration..."

ansible localhost -m community.general.mail -a "\
host=${SMTP_HOST:-localhost} \
port=${SMTP_PORT:-25} \
to=${TEST_EMAIL:-admin@example.com} \
subject='LVM Automation Test Email' \
body='This is a test email from the LVM automation system.'"

echo "Test email sent"
""",

    'setup_monitoring_cron.sh': """#!/bin/bash

Setup monitoring cron job

set -e

WEBHOOK_URL="${WEBHOOK_URL:-http://eda-controller:5000/webhook}"

echo "Setting up disk monitoring cron job..."

cat > /usr/local/bin/lvm-disk-monitor.sh << 'EOF'
#!/bin/bash
WEBHOOK_URL="$WEBHOOK_URL"
HOSTNAME="$(hostname)"

df -h | grep -E '^/dev/' | while read line; do
USAGE=$(echo $line | awk '{print $5}' | tr -d '%')
MOUNT=$(echo $line | awk '{print $6}')
DEVICE=$(echo $line | awk '{print $1}')

if [ $USAGE -ge 90 ]; then
    curl -X POST "$WEBHOOK_URL" \\
      -H 'Content-Type: application/json' \\
      -d "{\\"hostname\\": \\"$HOSTNAME\\", \\"disk_usage_percent\\": $USAGE, \\"mount_point\\": \\"$MOUNT\\", \\"device\\": \\"$DEVICE\\"}"
fi

done
EOF

chmod +x /usr/local/bin/lvm-disk-monitor.sh
(crontab -l 2>/dev/null; echo "*/5 * * * * /usr/local/bin/lvm-disk-monitor.sh") | crontab -

echo "Monitoring cron job installed"
"""
}

def __init__(self):
    self.root = Path("/home/sgallego/Downloads/GIT/Add_LVM_to_System_nutanix")
    os.chdir(self.root)
    self.backup = self.root / "backups"
    self.roles = ['servicenow_ticket_management', 'lvm_smart_extend', 'lvm_system_inspection', 
                 'lvm_extension_orchestrator', 'disk_usage_alerting']
    
def cls(self): os.system('clear')
def pause(self): input(f"\n{C.Y}Press [Enter]...{C.N}")
def backup_dir(self, name): 
    d = self.backup / f"{name}_{datetime.now():%Y%m%d_%H%M%S}"
    d.mkdir(parents=True, exist_ok=True)
    return d
    
def header(self, title):
    self.cls()
    print(f"{C.C}╔═════════════════════════════════════════╗{C.N}")
    print(f"{C.C}║  {title:^39}║{C.N}")
    print(f"{C.C}╚═════════════════════════════════════════╝{C.N}\n")
    
def create_role(self, name):
    """Create role structure"""
    rp = self.root / "roles" / name
    for d in ['tasks', 'defaults', 'vars', 'handlers', 'meta', 'templates', 'files']:
        (rp / d).mkdir(parents=True, exist_ok=True)
        
    (rp / "tasks/main.yml").write_text(self.ROLE_TASKS.get(name, 
        f"---\n- debug: {{msg: 'Role {name} needs implementation'}}\n"))
    (rp / "defaults/main.yml").write_text(self.ROLE_DEFAULTS.get(name, 
        f"---\n# {name.replace('_',' ').title()} Defaults\n"))
    (rp / "meta/main.yml").write_text(f"""---

galaxy_info:
author: System Administrator
description: {name.replace('',' ').title()}
license: MIT
min_ansible_version: 2.9
platforms: [{name: EL, versions: [8,9]}]
dependencies: []\n""")
(rp / "README.md").write_text(f"""# {name.replace('
',' ').title()}

Description

Handles {name.replace('_',' ')}.

Requirements

  • RHEL/CentOS 8+
  • Ansible 2.9+

Example

- hosts: servers
  roles: [{name}]
```\n""")
        return rp

    def create_playbook(self, name, content):
        """Create playbook file"""
        pb_path = self.root / "playbooks" / name
        if pb_path.exists():
            print(f"  {C.Y}⚠{C.N} {name} already exists, skipping")
            return False
        pb_path.write_text(content)
        print(f"  {C.G}✓{C.N} Created {name}")
        return True

    def create_script(self, name, content):
        """Create script file"""
        script_path = self.root / name
        if script_path.exists():
            print(f"  {C.Y}⚠{C.N} {name} already exists, skipping")
            return False
        script_path.write_text(content)
        script_path.chmod(0o755)
        print(f"  {C.G}✓{C.N} Created {name} (executable)")
        return True
        
    def missing_roles(self):
        """Get missing roles"""
        missing = []
        rd = self.root / "roles"
        for r in self.roles:
            rp = rd / r
            if not rp.exists() or not all((rp/f).exists() for f in ['tasks/main.yml','defaults/main.yml','meta/main.yml']):
                missing.append(r)
        return missing
        
    def create_missing(self, roles=None):
        """Create missing roles"""
        for r in roles or self.missing_roles():
            print(f"\n{C.Y}Creating: {r}{C.N}")
            self.create_role(r)
            print(f"{C.G}✓{C.N} Created {r}")

    def create_missing_playbooks(self):
        """Create missing ServiceNow and alert playbooks"""
        self.header("Create Mis...

</details>
Created from VS Code via the [GitHub Pull Request](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extension.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Copilot AI and others added 2 commits October 5, 2025 17:44
Co-authored-by: ShaddGallegos <7536008+ShaddGallegos@users.noreply.github.com>
Co-authored-by: ShaddGallegos <7536008+ShaddGallegos@users.noreply.github.com>
Copilot AI changed the title [WIP] please clean this up Add maintenance.py tool with fixed templates and comprehensive documentation Oct 5, 2025
Copilot AI requested a review from ShaddGallegos October 5, 2025 17:49
@ShaddGallegos
Copy link
Owner

@copilot 2026-02-25 09:25:05.786 [info] Python-envs extension version: 1.20.1
2026-02-25 09:25:05.786 [info]
=== Python Envs Configuration Levels ===
2026-02-25 09:25:05.786 [info] {
"section": "Python Envs Configuration Levels",
"defaultEnvManager": {
"workspaceFolderValue": "undefined",
"workspaceValue": "undefined",
"globalValue": "undefined",
"defaultValue": "ms-python.python:venv"
},
"defaultPackageManager": {
"workspaceFolderValue": "undefined",
"workspaceValue": "undefined",
"globalValue": "undefined",
"defaultValue": "ms-python.python:pip"
}
}
2026-02-25 09:25:05.786 [info] [pet] Starting Python Locator /home/sgallego/.vscode/extensions/ms-python.vscode-python-envs-1.20.1-linux-x64/python-env-tools/bin/pet server
2026-02-25 09:25:05.787 [warning] No workspace folders found for relative search path: .//.venv
2026-02-25 09:25:05.788 [info] [pet] configure: Sending configuration update: {"workspaceDirectories":[],"environmentDirectories":[],"pipenvExecutable":"pipenv","poetryExecutable":"poetry","cacheDirectory":"/home/sgallego/.config/Code/User/globalStorage/ms-python.vscode-python-envs/pythonLocator"}
2026-02-25 09:25:05.864 [info] Discovered env: /usr/bin/python
2026-02-25 09:25:05.892 [info] Discovered env: /usr/bin/python3.13
2026-02-25 09:25:05.947 [warning] No workspace folders found for relative search path: ./
/.venv
2026-02-25 09:25:05.948 [info] Conda not found, turning off conda features. [Error: Conda not found
at F (/home/sgallego/.vscode/extensions/ms-python.vscode-python-envs-1.20.1-linux-x64/dist/extension.js:2:578361)
at runNextTicks (node:internal/process/task_queues:65:5)
at process.processImmediate (node:internal/timers:453:9)
at async L (/home/sgallego/.vscode/extensions/ms-python.vscode-python-envs-1.20.1-linux-x64/dist/extension.js:2:578486)
at async t.registerCondaFeatures (/home/sgallego/.vscode/extensions/ms-python.vscode-python-envs-1.20.1-linux-x64/dist/extension.js:2:596321)
at async Promise.all (index 1)
at async Immediate. (/home/sgallego/.vscode/extensions/ms-python.vscode-python-envs-1.20.1-linux-x64/dist/extension.js:2:717155)]
2026-02-25 09:25:05.948 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":156,"breakdown":{"GlobalVirtualEnvs":0,"Locators":101,"Path":155,"Workspaces":0},"locators":{"Conda":49,"Homebrew":0,"LinuxGlobal":100,"PipEnv":0,"Pixi":0,"Poetry":0,"PyEnv":0,"Uv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
2026-02-25 09:25:06.004 [info] Discovered env: /usr/bin/python
2026-02-25 09:25:06.015 [info] Discovered env: /usr/bin/python3.13
2026-02-25 09:25:06.040 [warning] No workspace folders found for relative search path: .//.venv
2026-02-25 09:25:06.041 [info] Pipenv not found
2026-02-25 09:25:06.041 [info] Pipenv not found, turning off pipenv features. If you have pipenv installed in a non-standard location, set the "python.pipenvPath" setting.
2026-02-25 09:25:06.041 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":91,"breakdown":{"GlobalVirtualEnvs":0,"Locators":66,"Path":91,"Workspaces":0},"locators":{"Conda":47,"Homebrew":0,"LinuxGlobal":65,"PipEnv":0,"Pixi":0,"Poetry":0,"PyEnv":0,"Uv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
2026-02-25 09:25:06.097 [info] Discovered env: /usr/bin/python
2026-02-25 09:25:06.106 [info] Discovered env: /usr/bin/python3.13
2026-02-25 09:25:06.124 [warning] No workspace folders found for relative search path: ./
/.venv
2026-02-25 09:25:06.124 [info] Poetry not found, turning off poetry features.
2026-02-25 09:25:06.124 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":82,"breakdown":{"GlobalVirtualEnvs":0,"Locators":65,"Path":82,"Workspaces":0},"locators":{"Conda":49,"Homebrew":0,"LinuxGlobal":64,"PipEnv":0,"Pixi":0,"Poetry":0,"PyEnv":0,"Uv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
2026-02-25 09:25:06.183 [info] Discovered env: /usr/bin/python
2026-02-25 09:25:06.194 [info] Discovered env: /usr/bin/python3.13
2026-02-25 09:25:06.212 [info] Pyenv not found, turning off pyenv features.
2026-02-25 09:25:06.213 [info] [interpreterSelection] Applying initial environment selection for 0 workspace folder(s)
2026-02-25 09:25:06.214 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":86,"breakdown":{"GlobalVirtualEnvs":0,"Locators":68,"Path":86,"Workspaces":0},"locators":{"Conda":52,"Homebrew":0,"LinuxGlobal":68,"PipEnv":0,"Pixi":0,"Poetry":0,"PyEnv":0,"Uv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
2026-02-25 09:25:06.215 [info] [interpreterSelection] global: Python 3.13.12 (source: autoDiscovery)
2026-02-25 09:25:06.218 [info] Python API: Changed environment from undefined to Python 3.13.12 for: global
2026-02-25 09:25:06.218 [info] Internal: Changed environment from undefined to Python 3.13.12 for: global
2026-02-25 09:29:38.513 [info] Running: uv --version
2026-02-25 09:29:38.517 [info] Running: /usr/bin/python3.13 -m pip list
2026-02-25 09:29:38.528 [info] python: /usr/bin/python3.13: No module named pip

2026-02-25 09:29:38.529 [error] Error running pip list Failed to run python -m pip list
2026-02-25 09:29:38.529 [info] Package list retrieval attempted using pip, action can be done with uv if installed and setting alwaysUseUv is enabled.
2026-02-25 09:29:38.530 [error] Error refreshing packages Failed to run python -m pip list
2026-02-25 09:29:49.643 [info] Running: /usr/bin/python3.13 -m pip list
2026-02-25 09:29:49.650 [info] python: /usr/bin/python3.13: No module named pip

2026-02-25 09:29:49.652 [error] Error running pip list Failed to run python -m pip list
2026-02-25 09:29:49.652 [info] Package list retrieval attempted using pip, action can be done with uv if installed and setting alwaysUseUv is enabled.
2026-02-25 09:29:49.652 [error] Error refreshing packages Failed to run python -m pip list
2026-02-25 09:30:14.363 [info] Running: /usr/bin/python3.13 -m pip list
2026-02-25 09:30:14.370 [info] python: /usr/bin/python3.13: No module named pip

2026-02-25 09:30:14.372 [error] Error running pip list Failed to run python -m pip list
2026-02-25 09:30:14.372 [info] Package list retrieval attempted using pip, action can be done with uv if installed and setting alwaysUseUv is enabled.
2026-02-25 09:30:14.372 [error] Error refreshing packages Failed to run python -m pip list

@ShaddGallegos
Copy link
Owner

@copilot prevent the use of icons or emoji in all projects, roles, playbooks, markdown, or anything else

Co-authored-by: ShaddGallegos <7536008+ShaddGallegos@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 25, 2026

@copilot prevent the use of icons or emoji in all projects, roles, playbooks, markdown, or anything else

Done in commit 1692cbe. All icons and emoji have been replaced with plain ASCII equivalents in both files:

  • maintenance.py: box-drawing borders (+===+, |), checkmarks ([+]/[x]/[!]), bullets (-), section dividers (---)
  • MAINTENANCE_GUIDE.md: color emoji replaced with plain text labels (**Red**, **Green**, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants